'use strict';

const Controller = require('egg').Controller;

class UserController extends Controller {
    // resources  index / create / destroy / update
    // 查询
    async index() {
        let res = await this.ctx.service.user.index()
        this.ctx.body = res
    }
    async indexUser() {
        let res = await this.ctx.service.user.indexUser()
        this.ctx.body = res
    }
    // 添加
    async create() {
        let res = await this.ctx.service.user.create()
        console.log(res)
        this.ctx.body = {
            code: res.code,
            res: res
        }
    }
    // 删除
    async destroy() {
        let res = await this.ctx.service.user.destroy()
        this.ctx.body = {
            code: res.code,
            msg: "成功",
            res: res
        }

    }
    // 修改
    async update() {
        let res = await this.ctx.service.user.update()
        this.ctx.body = {
            code: 200,
            msg: "成功",
            res: res
        }
    }
}

module.exports = UserController;
